0 CpxTRS
↳1 TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID), 0 ms)
↳2 CpxWeightedTrs
↳3 TypeInferenceProof (BOTH BOUNDS(ID, ID), 0 ms)
↳4 CpxTypedWeightedTrs
↳5 CompletionProof (UPPER BOUND(ID), 0 ms)
↳6 CpxTypedWeightedCompleteTrs
↳7 CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID), 0 ms)
↳8 CpxRNTS
↳9 CompleteCoflocoProof (⇔, 419 ms)
↳10 BOUNDS(1, n^2)
cond1(s(x), y) → cond2(gr(s(x), y), s(x), y)
cond2(true, x, y) → cond1(y, y)
cond2(false, x, y) → cond1(p(x), y)
gr(0, x) → false
gr(s(x), 0) → true
gr(s(x), s(y)) → gr(x, y)
neq(0, 0) → false
neq(0, s(x)) → true
neq(s(x), 0) → true
neq(s(x), s(y)) → neq(x, y)
p(0) → 0
p(s(x)) → x
cond1(s(x), y) → cond2(gr(s(x), y), s(x), y) [1]
cond2(true, x, y) → cond1(y, y) [1]
cond2(false, x, y) → cond1(p(x), y) [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
neq(0, 0) → false [1]
neq(0, s(x)) → true [1]
neq(s(x), 0) → true [1]
neq(s(x), s(y)) → neq(x, y) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond1(s(x), y) → cond2(gr(s(x), y), s(x), y) [1]
cond2(true, x, y) → cond1(y, y) [1]
cond2(false, x, y) → cond1(p(x), y) [1]
gr(0, x) → false [1]
gr(s(x), 0) → true [1]
gr(s(x), s(y)) → gr(x, y) [1]
neq(0, 0) → false [1]
neq(0, s(x)) → true [1]
neq(s(x), 0) → true [1]
neq(s(x), s(y)) → neq(x, y) [1]
p(0) → 0 [1]
p(s(x)) → x [1]
cond1 :: s:0 → s:0 → cond1:cond2 s :: s:0 → s:0 cond2 :: true:false → s:0 → s:0 → cond1:cond2 gr :: s:0 → s:0 → true:false true :: true:false false :: true:false p :: s:0 → s:0 0 :: s:0 neq :: s:0 → s:0 → true:false |
cond1(v0, v1) → null_cond1 [0]
null_cond1
Runtime Complexity Weighted TRS with Types. The TRS R consists of the following rules:
The TRS has the following type information:
Rewrite Strategy: INNERMOST |
true => 1
false => 0
0 => 0
null_cond1 => 0
cond1(z, z') -{ 1 }→ cond2(gr(1 + x, y), 1 + x, y) :|: x >= 0, y >= 0, z = 1 + x, z' = y
cond1(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
cond2(z, z', z'') -{ 1 }→ cond1(y, y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
cond2(z, z', z'') -{ 1 }→ cond1(p(x), y) :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
gr(z, z') -{ 1 }→ gr(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
gr(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
gr(z, z') -{ 1 }→ 0 :|: z' = x, x >= 0, z = 0
neq(z, z') -{ 1 }→ neq(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
neq(z, z') -{ 1 }→ 1 :|: z' = 1 + x, x >= 0, z = 0
neq(z, z') -{ 1 }→ 1 :|: x >= 0, z = 1 + x, z' = 0
neq(z, z') -{ 1 }→ 0 :|: z = 0, z' = 0
p(z) -{ 1 }→ x :|: x >= 0, z = 1 + x
p(z) -{ 1 }→ 0 :|: z = 0
eq(start(V, V1, V4),0,[cond1(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[cond2(V, V1, V4, Out)],[V >= 0,V1 >= 0,V4 >= 0]). eq(start(V, V1, V4),0,[gr(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[neq(V, V1, Out)],[V >= 0,V1 >= 0]). eq(start(V, V1, V4),0,[p(V, Out)],[V >= 0]). eq(cond1(V, V1, Out),1,[gr(1 + V2, V3, Ret0),cond2(Ret0, 1 + V2, V3, Ret)],[Out = Ret,V2 >= 0,V3 >= 0,V = 1 + V2,V1 = V3]). eq(cond2(V, V1, V4, Out),1,[cond1(V5, V5, Ret1)],[Out = Ret1,V1 = V6,V4 = V5,V = 1,V6 >= 0,V5 >= 0]). eq(cond2(V, V1, V4, Out),1,[p(V7, Ret01),cond1(Ret01, V8, Ret2)],[Out = Ret2,V1 = V7,V4 = V8,V7 >= 0,V8 >= 0,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 0,V1 = V9,V9 >= 0,V = 0]). eq(gr(V, V1, Out),1,[],[Out = 1,V10 >= 0,V = 1 + V10,V1 = 0]). eq(gr(V, V1, Out),1,[gr(V11, V12, Ret3)],[Out = Ret3,V1 = 1 + V12,V11 >= 0,V12 >= 0,V = 1 + V11]). eq(neq(V, V1, Out),1,[],[Out = 0,V = 0,V1 = 0]). eq(neq(V, V1, Out),1,[],[Out = 1,V1 = 1 + V13,V13 >= 0,V = 0]). eq(neq(V, V1, Out),1,[],[Out = 1,V14 >= 0,V = 1 + V14,V1 = 0]). eq(neq(V, V1, Out),1,[neq(V15, V16, Ret4)],[Out = Ret4,V1 = 1 + V16,V15 >= 0,V16 >= 0,V = 1 + V15]). eq(p(V, Out),1,[],[Out = 0,V = 0]). eq(p(V, Out),1,[],[Out = V17,V17 >= 0,V = 1 + V17]). eq(cond1(V, V1, Out),0,[],[Out = 0,V18 >= 0,V19 >= 0,V = V18,V1 = V19]). input_output_vars(cond1(V,V1,Out),[V,V1],[Out]). input_output_vars(cond2(V,V1,V4,Out),[V,V1,V4],[Out]). input_output_vars(gr(V,V1,Out),[V,V1],[Out]). input_output_vars(neq(V,V1,Out),[V,V1],[Out]). input_output_vars(p(V,Out),[V],[Out]). |
CoFloCo proof output:
Preprocessing Cost Relations
=====================================
#### Computed strongly connected components
0. non_recursive : [p/2]
1. recursive : [gr/3]
2. recursive : [cond1/3,cond2/4]
3. recursive : [neq/3]
4. non_recursive : [start/3]
#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into p/2
1. SCC is partially evaluated into gr/3
2. SCC is partially evaluated into cond1/3
3. SCC is partially evaluated into neq/3
4. SCC is partially evaluated into start/3
Control-Flow Refinement of Cost Relations
=====================================
### Specialization of cost equations p/2
* CE 9 is refined into CE [20]
* CE 8 is refined into CE [21]
### Cost equations --> "Loop" of p/2
* CEs [20] --> Loop 14
* CEs [21] --> Loop 15
### Ranking functions of CR p(V,Out)
#### Partial ranking functions of CR p(V,Out)
### Specialization of cost equations gr/3
* CE 15 is refined into CE [22]
* CE 14 is refined into CE [23]
* CE 13 is refined into CE [24]
### Cost equations --> "Loop" of gr/3
* CEs [23] --> Loop 16
* CEs [24] --> Loop 17
* CEs [22] --> Loop 18
### Ranking functions of CR gr(V,V1,Out)
* RF of phase [18]: [V,V1]
#### Partial ranking functions of CR gr(V,V1,Out)
* Partial RF of phase [18]:
- RF of loop [18:1]:
V
V1
### Specialization of cost equations cond1/3
* CE 12 is refined into CE [25]
* CE 10 is refined into CE [26]
* CE 11 is refined into CE [27,28]
### Cost equations --> "Loop" of cond1/3
* CEs [28] --> Loop 19
* CEs [26] --> Loop 20
* CEs [27] --> Loop 21
* CEs [25] --> Loop 22
### Ranking functions of CR cond1(V,V1,Out)
* RF of phase [20]: [V]
#### Partial ranking functions of CR cond1(V,V1,Out)
* Partial RF of phase [20]:
- RF of loop [20:1]:
V
### Specialization of cost equations neq/3
* CE 19 is refined into CE [29]
* CE 18 is refined into CE [30]
* CE 17 is refined into CE [31]
* CE 16 is refined into CE [32]
### Cost equations --> "Loop" of neq/3
* CEs [30] --> Loop 23
* CEs [31] --> Loop 24
* CEs [32] --> Loop 25
* CEs [29] --> Loop 26
### Ranking functions of CR neq(V,V1,Out)
* RF of phase [26]: [V,V1]
#### Partial ranking functions of CR neq(V,V1,Out)
* Partial RF of phase [26]:
- RF of loop [26:1]:
V
V1
### Specialization of cost equations start/3
* CE 3 is refined into CE [33]
* CE 2 is refined into CE [34,35]
* CE 4 is refined into CE [36]
* CE 5 is refined into CE [37,38,39,40]
* CE 6 is refined into CE [41,42,43,44,45,46]
* CE 7 is refined into CE [47,48]
### Cost equations --> "Loop" of start/3
* CEs [44] --> Loop 27
* CEs [38,43,48] --> Loop 28
* CEs [33,36,39,40,45,46] --> Loop 29
* CEs [34,35,37,41,42,47] --> Loop 30
### Ranking functions of CR start(V,V1,V4)
#### Partial ranking functions of CR start(V,V1,V4)
Computing Bounds
=====================================
#### Cost of chains of p(V,Out):
* Chain [15]: 1
with precondition: [V=0,Out=0]
* Chain [14]: 1
with precondition: [V=Out+1,V>=1]
#### Cost of chains of gr(V,V1,Out):
* Chain [[18],17]: 1*it(18)+1
Such that:it(18) =< V
with precondition: [Out=0,V>=1,V1>=V]
* Chain [[18],16]: 1*it(18)+1
Such that:it(18) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [17]: 1
with precondition: [V=0,Out=0,V1>=0]
* Chain [16]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of cond1(V,V1,Out):
* Chain [[20],22]: 4*it(20)+1*s(3)+0
Such that:aux(3) =< V
it(20) =< aux(3)
s(3) =< it(20)*aux(3)
with precondition: [Out=0,V>=1,V1>=V]
* Chain [22]: 0
with precondition: [Out=0,V>=0,V1>=0]
* Chain [21,22]: 3
with precondition: [V1=0,Out=0,V>=1]
* Chain [19,[20],22]: 5*it(20)+1*s(3)+3
Such that:aux(4) =< V1
it(20) =< aux(4)
s(3) =< it(20)*aux(4)
with precondition: [Out=0,V1>=1,V>=V1+1]
* Chain [19,22]: 1*s(4)+3
Such that:s(4) =< V1
with precondition: [Out=0,V1>=1,V>=V1+1]
#### Cost of chains of neq(V,V1,Out):
* Chain [[26],25]: 1*it(26)+1
Such that:it(26) =< V
with precondition: [Out=0,V=V1,V>=1]
* Chain [[26],24]: 1*it(26)+1
Such that:it(26) =< V
with precondition: [Out=1,V>=1,V1>=V+1]
* Chain [[26],23]: 1*it(26)+1
Such that:it(26) =< V1
with precondition: [Out=1,V1>=1,V>=V1+1]
* Chain [25]: 1
with precondition: [V=0,V1=0,Out=0]
* Chain [24]: 1
with precondition: [V=0,Out=1,V1>=1]
* Chain [23]: 1
with precondition: [V1=0,Out=1,V>=1]
#### Cost of chains of start(V,V1,V4):
* Chain [30]: 12*s(14)+2*s(17)+4*s(21)+1*s(22)+5
Such that:s(18) =< V1
aux(6) =< V4
s(14) =< aux(6)
s(21) =< s(18)
s(22) =< s(21)*s(18)
s(17) =< s(14)*aux(6)
with precondition: [V=0]
* Chain [29]: 10*s(26)+2*s(28)+8*s(32)+6*s(33)+1*s(34)+1*s(35)+4
Such that:aux(7) =< V4
aux(8) =< V
aux(9) =< V1
s(33) =< aux(8)
s(32) =< aux(9)
s(34) =< s(33)*aux(8)
s(35) =< s(32)*aux(9)
s(26) =< aux(7)
s(28) =< s(26)*aux(7)
with precondition: [V>=0,V1>=0]
* Chain [28]: 1
with precondition: [V>=1]
* Chain [27]: 1*s(40)+1
Such that:s(40) =< V1
with precondition: [V=V1,V>=1]
Closed-form bounds of start(V,V1,V4):
-------------------------------------
* Chain [30] with precondition: [V=0]
- Upper bound: nat(V1)*4+5+nat(V1)*nat(V1)+nat(V4)*12+nat(V4)*2*nat(V4)
- Complexity: n^2
* Chain [29] with precondition: [V>=0,V1>=0]
- Upper bound: 6*V+4+V*V+8*V1+V1*V1+nat(V4)*10+nat(V4)*2*nat(V4)
- Complexity: n^2
* Chain [28] with precondition: [V>=1]
- Upper bound: 1
- Complexity: constant
* Chain [27] with precondition: [V=V1,V>=1]
- Upper bound: V1+1
- Complexity: n
### Maximum cost of start(V,V1,V4): nat(V1)*3+3+nat(V1)*nat(V1)+nat(V4)*10+nat(V4)*2*nat(V4)+max([nat(V4)*2+1,6*V+V*V+nat(V1)*4])+nat(V1)+1
Asymptotic class: n^2
* Total analysis performed in 286 ms.